www.gusucode.com > VC++ SuperReport 超级报表控件源码程序 > VC++ SuperReport 超级报表控件源码程序\code\pubfunc.cpp
//Download by http://www.NewXing.com // pubfunc.cpp: implementation of the pubfunc class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "pubfunc.h" CString GetSysDate() { CString strTemp; CTime t = CTime::GetCurrentTime(); strTemp.Format("%04d/%02d/%02d", t.GetYear(), t.GetMonth(), t.GetDay()); return strTemp; } CString GetSysTime() { CString strTime; CTime t = CTime::GetCurrentTime(); strTime.Format("%02d:%02d:%02d", t.GetHour(), t.GetMinute(), t.GetSecond()); return strTime; } CString GetPath() { CString strPath; char exePath[MAX_PATH]; GetModuleFileName(NULL,exePath,MAX_PATH); strPath=exePath; strPath.Replace("/","\\"); int pos=strPath.ReverseFind('\\'); if(pos>=0) strPath=strPath.Left(pos+1); return strPath; } BOOL SetAccessODBC(char *dstName) { CString szDesc; char dbName[60]; char tmpPath[MAX_PATH]; sprintf(dbName,"%s.mdb",dstName); strcpy(tmpPath,GetPath()); szDesc.Format("DSN=%s|DESCRIPTION=%s|DBQ=%s|FIL=MicrosoftAccess|DEFAULTDIR=%s|", dstName,dstName,dbName,tmpPath); for(int i=0;i<szDesc.GetLength();i++){ if(szDesc.GetAt(i)=='|') szDesc.SetAt(i,'\0'); } SQLConfigDataSource(NULL,ODBC_ADD_DSN, "Microsoft Access Driver (*.mdb)\0", (LPCSTR)szDesc); return TRUE; }